<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<script src="js/mui.js"></script>
		<script src="./utils/myRequest.js"></script>
		<script type="text/javascript">
			mui.init();
			var user = null;
			mui.plusReady(function () {
			    //退出登录功能
				document.getElementById("logoutBtn").addEventListener("tap",function(){
					//首先先清除本地存储
					store.setItem(null);
					
					//跳转到登录页面
					plus.webview.open("./login.html","login.html");
					
					//关闭当前页面
					plus.webview.currentWebview().close();
				});
				
				//获取登录对象
				user = store.getItem();
				
				//获取用户名称
				var username = document.getElementById("username");
				//获取昵称
				var nickname = document.getElementById("nickname");
				
				updateUserMinHeader();
				
				username.innerHTML = user.username;
				nickname.innerHTML = user.nickname;
				
				//给头像绑定点击事件
				//跳转到修改头像页面
				document.getElementById("uploadBtn").addEventListener("tap",function(){
					plus.webview.open("./actave.html","actave.html");
				});
				
				
			});
			
			//更新用户头像的方法
			function updateUserMinHeader(){
				//获取头像
				var minImg = document.getElementById("minImg");
				
				//判断当前用户是否有头像，如果没有默认就行
				if(user.minHeand != null){
					minImg.src = user.minHeand;
				}
			}
			
		</script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">我的</h1>
		</header>
		
		<!-- 个人用户页面 -->
		<ul class="mui-table-view" style="margin-top: 50px;line-height: 45px;">
			<li class="mui-table-view-cell mui-media">
				<a href="javascript:;" id="uploadBtn">
					<img class="mui-media-object mui-pull-right" id="minImg" src="./img/tou.jpg">
					<div class="mui-media-body">
						头像
					</div>
				</a>
			</li>
			
		</ul>
		
		<ul class="mui-table-view" style="margin-top: 20px;">
			<li class="mui-table-view-cell mui-media">
				<a href="javascript:;">
					<div class=" mui-pull-right" id="username"></div>
					<div class="mui-media-body">
						用户名
					</div>
				</a>
			</li>
			<li class="mui-table-view-cell mui-media">
				<a href="javascript:;">
					<div class=" mui-pull-right" id="nickname"></div>
					<div class="mui-media-body">
					    昵称
					</div>
				</a>
			</li>
		</ul>
		
		<ul class="mui-table-view" style="margin-top: 50px;text-align: center;color: red;">
			<li class="mui-table-view-cell mui-media">
				<a href="javascript:;" id="logoutBtn">
					注销账户
				</a>
			</li>
		</ul>
	</body>

</html>
